#ifndef MATSCENE_H
#define MATSCENE_H

#include <QGraphicsScene>
#include "matwin_global.h"
#include "mat.h"

class MatItem;

class MATWINSHARED_EXPORT MatScene : public QGraphicsScene
{
    Q_OBJECT
public:
    using ItemGrid = QVector<QVector<MatItem *>>;

    MatScene(const Mat &mat, const QRectF &sceneRect, QObject *parent = 0);
    virtual ~MatScene();

    MatItem *itemAt(qint32 m, qint32 n);
    void setItemsColor(qint32 type, const QColor &color);

private:
    void setupUi(const Mat &mat, const QRectF &sceneRect);

    void addMesh(const Mat &mat, const QRectF &sceneRect);
    void addGrid(const Mat &mat, const QRectF &sceneRect);

    Mat m_mat;

    QPen m_pen;
    QBrush m_brush;

    QGraphicsRectItem *m_gridItem;
    ItemGrid m_itemGrid;

    Q_DISABLE_COPY(MatScene)
};

#endif // MATSCENE_H
